<?php

/*
  Action	$4

  +1 Buy
  Trash a card from your hand. +$ equal to its cost.

 */

class Salvager extends Card implements iAction, iKingdom, iSeaside {

    public function __construct() {
        parent::__construct("Salvager", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Buy",
            "Trash a card from your hand. +$ equal to its cost.");
    }

    public function play(Game $game, $isRealCard) {

        $game->addBuys(1);
         ScreenDisplay::addScreenMessage($game, true, "get +1 buy", "gets +1 buy");
         
        $cards = $game->getPlayHand();


        if (sizeof($cards) > 0) {
            $cards = getUniqueCards($cards);
            if (sizeof($cards) > 1) {
                $output = MySocket::GetUserReply($game, Input_ChooseOne, $cards, 1, 1, null, "Choose card to trash");
                $card_name = $output[0];
            } else {
                $card_name = $cards[0];
            }

            $card = $game->moveCardFromPileToPile($card_name, PlayHand, Trash);
            $price = $card->getPrice($game);
            $coins = $price->getCoins();

            ScreenDisplay::addScreenMessage($game, true, "trash " . nicePrint($card) . " and get +$coins$", "trashes " . ScreenDisplay::$LMSG . " and gets +$coins$");
            $game->addMoney($coins);
        } else {
            ScreenDisplay::addScreenMessage($game, true, "trash nothing", "trashes nothing");
        }
        $game->cardActionFinished();
        return true;
    }

}

?>